| print(hashTable) |
| print("Collision: " + str(i)) |
| itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
| hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| for i in itemsToAdd: |
| else: |
| idx = i % 20 |
| if hashTable[idx] == None: |
| hashTable[idx] = i |
| print(hashTable) |
| print("Collision: " + str(i)) |
| itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
| hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| for i in itemsToAdd: |
| else: |
| idx = i % 20 |
| if hashTable[idx] == None: |
| hashTable[idx] = i |
| 1 | hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| 2 | itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
| 3 | |
| 4 | for i in itemsToAdd: |
| 5 | idx = i % 20 |
| 6 | if hashTable[idx] == None: |
| 7 | hashTable[idx] = i |
| 8 | else: |
| 9 | print("Collision: " + str(i)) |
| 10 | |
| 11 | print(hashTable) |
| print(hashTable) |
| break |
| for x in range(len(hashTable)): |
| if hashTable[tempIdx] == None: |
| tempIdx = idx + x |
| if tempIdx == 20: |
| tempIdx = 0 |
| itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
| for i in itemsToAdd: |
| hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| idx = i % 20 |
| hashTable[tempIdx] = i |
| print(hashTable) |
| break |
| for x in range(len(hashTable)): |
| if hashTable[tempIdx] == None: |
| tempIdx = idx + x |
| if tempIdx == 20: |
| tempIdx = 0 |
| itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
| for i in itemsToAdd: |
| hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| idx = i % 20 |
| hashTable[tempIdx] = i |
| 1 | hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| 2 | itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
| 3 | |
| 4 | for i in itemsToAdd: |
| 5 | idx = i % 20 |
| 6 | for x in range(len(hashTable)): |
| 7 | tempIdx = idx + x |
| 8 | if tempIdx == 20: |
| 9 | tempIdx = 0 |
| 10 | if hashTable[tempIdx] == None: |
| 11 | hashTable[tempIdx] = i |
| 12 | break |
| 13 | print(hashTable) |
| return t |
| t = t + ord(n) |
| tempIdx = 0 |
| hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| t = t % 20 |
| hashTable[tempIdx] = name |
| if hashTable[tempIdx] == None: |
| for n in name: |
| print(hashTable) |
| if tempIdx == 20: |
| itemsToAdd = ["Harry","Sebastian","Greg","Julia","Karen","Jamie","Gordon","Georgia","Zane"] |
| def hashFunction(name): |
| tempIdx = idx + x |
| t = 0 |
| for x in range(len(hashTable)): |
| for name in itemsToAdd: |
| break |
| idx = hashFunction(name) |
| print(idx) |
| return t |
| t = t + ord(n) |
| tempIdx = 0 |
| hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| t = t % 20 |
| hashTable[tempIdx] = name |
| if hashTable[tempIdx] == None: |
| for n in name: |
| print(hashTable) |
| if tempIdx == 20: |
| itemsToAdd = ["Harry","Sebastian","Greg","Julia","Karen","Jamie","Gordon","Georgia","Zane"] |
| def hashFunction(name): |
| tempIdx = idx + x |
| t = 0 |
| for x in range(len(hashTable)): |
| for name in itemsToAdd: |
| break |
| idx = hashFunction(name) |
| print(idx) |
| 1 | hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
| 2 | itemsToAdd = ["Harry","Sebastian","Greg","Julia","Karen","Jamie","Gordon","Georgia","Zane"] |
| 3 | |
| 4 | def hashFunction(name): |
| 5 | t = 0 |
| 6 | for n in name: |
| 7 | t = t + ord(n) |
| 8 | t = t % 20 |
| 9 | return t |
| 10 | |
| 11 | for name in itemsToAdd: |
| 12 | idx = hashFunction(name) |
| 13 | print(idx) |
| 14 | for x in range(len(hashTable)): |
| 15 | tempIdx = idx + x |
| 16 | if tempIdx == 20: |
| 17 | tempIdx = 0 |
| 18 | if hashTable[tempIdx] == None: |
| 19 | hashTable[tempIdx] = name |
| 20 | break |
| 21 | print(hashTable) |
| hashTable[tempIdx] = dictionary |
| t = 0 |
| def hashFunction(key): |
| print(hashTable) |
| for x in range(len(hashTable)): |
| print(idx) |
| break |
| return t % 64 |
| tempIdx = (idx + x) % 64 |
| for dictionary in itemsToAdd: |
| strid = str(key["id"]) |
| if hashTable[tempIdx] == None: |
| t = t + int(strid[i]) |
| idx = hashFunction(dictionary) |
| for i in range(len(strid)): |
| hashTable[tempIdx] = dictionary |
| t = 0 |
| def hashFunction(key): |
| print(hashTable) |
| for x in range(len(hashTable)): |
| print(idx) |
| break |
| return t % 64 |
| tempIdx = (idx + x) % 64 |
| for dictionary in itemsToAdd: |
| strid = str(key["id"]) |
| if hashTable[tempIdx] == None: |
| t = t + int(strid[i]) |
| idx = hashFunction(dictionary) |
| for i in range(len(strid)): |
| 1 | def hashFunction(key): |
| 2 | t = 0 |
| 3 | strid = str(key["id"]) |
| 4 | for i in range(len(strid)): |
| 5 | t = t + int(strid[i]) |
| 6 | return t % 64 |
| 7 | |
| 8 | |
| 9 | for dictionary in itemsToAdd: |
| 10 | idx = hashFunction(dictionary) |
| 11 | print(idx) |
| 12 | for x in range(len(hashTable)): |
| 13 | tempIdx = (idx + x) % 64 |
| 14 | if hashTable[tempIdx] == None: |
| 15 | hashTable[tempIdx] = dictionary |
| 16 | break |
| 17 | print(hashTable) |
| t = t * int(part) |
| break |
| for dictionary in itemsToAdd: |
| key = "0" + key |
| while len(key) % 4 != 0: |
| t = 1 |
| idx = hashFunction(dictionary) |
| return t % 64 |
| def hashFunction(key): |
| key = str(key["id"]) |
| part = key[4*x:4*(x+1)] |
| for x in range(len(hashTable)): |
| if hashTable[tempIdx] == None: |
| tempIdx = (idx + x) % 64 |
| for x in range(len(key)//4): |
| print(hashTable) |
| hashTable[tempIdx] = dictionary |
| t = t * int(part) |
| break |
| for dictionary in itemsToAdd: |
| key = "0" + key |
| while len(key) % 4 != 0: |
| t = 1 |
| idx = hashFunction(dictionary) |
| return t % 64 |
| def hashFunction(key): |
| key = str(key["id"]) |
| part = key[4*x:4*(x+1)] |
| for x in range(len(hashTable)): |
| if hashTable[tempIdx] == None: |
| tempIdx = (idx + x) % 64 |
| for x in range(len(key)//4): |
| print(hashTable) |
| hashTable[tempIdx] = dictionary |
| 1 | def hashFunction(key): |
| 2 | key = str(key["id"]) |
| 3 | while len(key) % 4 != 0: |
| 4 | key = "0" + key |
| 5 | for x in range(len(key)//4): |
| 6 | t = 1 |
| 7 | part = key[4*x:4*(x+1)] |
| 8 | t = t * int(part) |
| 9 | return t % 64 |
| 10 | |
| 11 | for dictionary in itemsToAdd: |
| 12 | idx = hashFunction(dictionary) |
| 13 | for x in range(len(hashTable)): |
| 14 | tempIdx = (idx + x) % 64 |
| 15 | if hashTable[tempIdx] == None: |
| 16 | hashTable[tempIdx] = dictionary |
| 17 | break |
| 18 | print(hashTable) |
| break |
| if x == 1: |
| print(num) |
| key = str(key["id"]) |
| def hashFunction(key,size): |
| break |
| if hashTable[tempIdx] == None: |
| for x in range(len(hashTable)): |
| key = "0" + key |
| if collision == True: |
| while len(key) % 4 != 0: |
| idx = hashFunction(dictionary,num) |
| tempIdx = (idx + x) % num |
| for x in range(len(key)//4): |
| break |
| collision = True |
| if collision == False: |
| for dictionary in itemsToAdd: |
| hashTable[tempIdx] = dictionary |
| hashTable = [None]*num |
| return t % size |
| part = key[4*x:4*(x+1)] |
| t = t * int(part) |
| collision = False |
| t = 1 |
| for num in range(64,150): |
| break |
| if x == 1: |
| print(num) |
| key = str(key["id"]) |
| def hashFunction(key,size): |
| break |
| if hashTable[tempIdx] == None: |
| for x in range(len(hashTable)): |
| key = "0" + key |
| if collision == True: |
| while len(key) % 4 != 0: |
| idx = hashFunction(dictionary,num) |
| tempIdx = (idx + x) % num |
| for x in range(len(key)//4): |
| break |
| collision = True |
| if collision == False: |
| for dictionary in itemsToAdd: |
| hashTable[tempIdx] = dictionary |
| hashTable = [None]*num |
| return t % size |
| part = key[4*x:4*(x+1)] |
| t = t * int(part) |
| collision = False |
| t = 1 |
| for num in range(64,150): |
| 1 | def hashFunction(key,size): |
| 2 | key = str(key["id"]) |
| 3 | while len(key) % 4 != 0: |
| 4 | key = "0" + key |
| 5 | for x in range(len(key)//4): |
| 6 | t = 1 |
| 7 | part = key[4*x:4*(x+1)] |
| 8 | t = t * int(part) |
| 9 | return t % size |
| 10 | |
| 11 | for num in range(64,150): |
| 12 | hashTable = [None]*num |
| 13 | collision = False |
| 14 | for dictionary in itemsToAdd: |
| 15 | idx = hashFunction(dictionary,num) |
| 16 | for x in range(len(hashTable)): |
| 17 | if x == 1: |
| 18 | collision = True |
| 19 | break |
| 20 | tempIdx = (idx + x) % num |
| 21 | if hashTable[tempIdx] == None: |
| 22 | hashTable[tempIdx] = dictionary |
| 23 | break |
| 24 | if collision == True: |
| 25 | break |
| 26 | if collision == False: |
| 27 | print(num) |